package cn.com.headfree.deptuser.service.impl;

import cn.com.headfree.base.entity.TOuterDeptUser;
import cn.com.headfree.base.entity.TOuterUser;
import cn.com.headfree.base.initData.InitData;
import cn.com.headfree.deptuser.dao.TOuterDeptUserDao;
import cn.com.headfree.deptuser.dao.TOuterUserDao;
import cn.com.headfree.deptuser.service.TOuterUserService;
import cn.com.headfree.vo.UserDetailVo;
import cn.com.headfree.vo.UserNumVo;
import cn.com.headfree.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Properties;

/**
 * Title:
 * Description:
 * Copyright: Copyright (c) 2017 
 * Company: www.headfree.com.cn 
 * @author fengya
 * @version 1.0
 * @date  2019年4月24日 下午8:27:00
 */
@Service("tOuterUserService")
public class TOuterUserServiceImpl implements TOuterUserService {

	@Autowired
	private TOuterDeptUserDao tOuterDeptUserDao;
	@Autowired
	private TOuterUserDao tOuterUserDao;
	@Override
	public List<UserVo> findDeptUserAll() {
		return this.tOuterDeptUserDao.findDeptUserAll();
	}

	@Override
	public List<UserNumVo> findUserNumByUserType() {
		return this.tOuterUserDao.findUserNumByUserType();
	}

	@Override
	public List<UserDetailVo> getUserList(String userName) {
		List<UserDetailVo> userlist=tOuterUserDao.getUserList(userName);
		Properties p=(Properties) InitData.getInstance().getData().get("USER_TYPE");
		for(UserDetailVo ud:userlist) {
			String userType=ud.getUserType();
			if(userType!=null) {
				ud.setUserTypeName(p.getProperty(userType));
			}
		}
		return userlist;
	}

	@Override
	public List<UserDetailVo> getUserListByUserType(String userName,String userType) {
		List<UserDetailVo> userlist=tOuterUserDao.getUserListByUserType(userName,userType);
		if("1".equals(userType)){//非信通员工
			Properties p=(Properties) InitData.getInstance().getData().get("USER_TYPE");
			if(userlist != null && userlist.size()>0){
				for(UserDetailVo ud:userlist) {
					String type = ud.getUserType();
					if(type!=null) {
						ud.setUserTypeName(p.getProperty(type));
					}else{
						ud.setUserTypeName("外委人员");
					}
				}
			}
		}else{
			for(UserDetailVo ud:userlist) {
				ud.setUserTypeName("信通员工");
			}
		}
		return userlist;
	}

	@Override
	public List<TOuterUser> findALL() {
		return this.tOuterUserDao.findAll();
	}

	@Override
	public List<TOuterDeptUser> findDeptAndUserAll() {
		return this.tOuterDeptUserDao.findAll();
	}
	
}
